package org.supper.auth.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.supper.auth.entity.Auth;
import org.supper.auth.service.LoginService;
import org.supper.auth.utils.JsonResult;

import javax.annotation.Resource;

@RequestMapping("/auth")
@RestController
public class LoginController {

    @Resource
    private LoginService loginService;
    @ApiOperation(value = "登录模块",notes = "登录")
    @GetMapping("/login")
    public JsonResult<Auth> login(@ApiParam(value = "用户名",required = true) @RequestParam(value = "userName") String userName,
                                  @ApiParam(value = "密码",required = true) @RequestParam(value = "password") String password) {

        Auth auth = loginService.login(userName, password);
        return JsonResult.success(auth);
    }

    @GetMapping("/phoneLogin")
    public JsonResult<Auth> phoneLogin(@ApiParam(value = "手机号",required = true) @RequestParam(value = "phone") String phone,
                                  @ApiParam(value = "验证码",required = true) @RequestParam(value = "verifyCode") String code) {

        Auth auth = loginService.phoneLogin(phone, code);
        return JsonResult.success(auth);
    }

    @PostMapping("/getTest")
    public void getTest(){
        System.out.println("111111111111111111");
    }
}
